package com.demo.web.admin.tag;

import java.io.IOException;
import java.io.Writer;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.demo.web.admin.service.SysUserService;

import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;

@Component
public class SysParameterTag implements TemplateDirectiveModel {
	
	private static Logger logger = LoggerFactory.getLogger(SysParameterTag.class);
	
	@Autowired
	private SysUserService sysUserService;

	@Override
	public void execute(Environment env, Map map, TemplateModel[] model, TemplateDirectiveBody body)
			throws TemplateException, IOException {
		
			Writer out = env.getOut();
		
		 	String code = map.get("code").toString();
	        
	        out.write(sysUserService.getParam(code));
	        if (body != null) {
	            body.render(env.getOut());
	        }

	}

}
